﻿using System;
using System.Collections.Generic;
using System.Text;

namespace 设计模式
{
    class yangrouchuan
    {

        public static void main()
        {
            barbecuer boy = new barbecuer();
            comand command1 = new bakemutton_command(boy);
            comand command2 = new bakemutton_command(boy);
            comand command3 = new bakechicken_command(boy);

            waiter girl = new waiter();

            girl.set_order(command1);
            girl.notify();

            girl.set_order(command2);
            girl.notify();

            girl.set_order(command3);
            girl.notify();

            Console.Read();
        }

    }

    public class barbecuer
    {
        public void bakemutton()
        {
            Console.WriteLine("烤羊肉");
        }

        public void bakechicken()
        {
            Console.WriteLine("烤鸡翅");
        }
    }

    public class comand
    {
        public barbecuer receiver;

        public comand(barbecuer receiver)
        {
            this.receiver = receiver;
        }

        public virtual void excutecommand()
        {

        }

    }

    public class bakemutton_command : comand
    {
        public bakemutton_command(barbecuer receiver) : base(receiver) { }

        public override void excutecommand()
        {
            receiver.bakemutton();
        }

    }

    public class bakechicken_command : comand
    {
        public bakechicken_command(barbecuer receiver) : base(receiver) { }

        public override void excutecommand()
        {
            receiver.bakechicken();
        }

    }

    public class waiter
    {
        private comand command1;

        public void set_order(comand command1)
        {
            this.command1 = command1;

        }

        public void notify()
        {
            command1.excutecommand();
        }

    }








}
